package com.yoda.controller;


import com.yoda.dto.UserDto;
import com.yoda.dto.UserPageQuery;
import com.yoda.result.Result;
import com.yoda.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author itcast
 * @since 2023-05-15
 */
@RestController
@RequestMapping("/sys_user")
public class SysUserController {
    @Autowired
    private ISysUserService service;

    /**
     * 用户列表-分页
     * @param userPageQuery
     * @return
     */
    @GetMapping("/list")
    public Result userPageQuery(UserPageQuery userPageQuery){
        return service.userPageQuery(userPageQuery);
    }

    /**
     * 根据id进行管理员删除
     * @param id
     * @return
     */
    @GetMapping("/del")
    public Result deleteById(String id){
        return service.deleteById(id);
    }

    /**
     *  管理员添加
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public Result addUser(@RequestBody UserDto dto){
        return service.addUser(dto);
    }

    /**
     * 管理员修改
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public Result updateUser(@RequestBody UserDto dto){
        return service.updateUser(dto);

    }

    /**
     * 根据id获取角色详情
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    public Result rowInfo(String id){
        return service.rowInfo(id);
    }



}

